home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / pippki.jar / content / pippki / pref-validation.js < prev    next >
Encoding:
Text File  |  2007-05-30  |  4.6 KB  |  130 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is mozilla.org code.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Netscape Communications Corporation.
  18.  * Portions created by the Initial Developer are Copyright (C) 2001
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *   David Drinan <ddrinan@netscape.com>
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
  39. const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
  40. const nsIOCSPResponder = Components.interfaces.nsIOCSPResponder;
  41. const nsISupportsArray = Components.interfaces.nsISupportsArray;
  42.  
  43. var certdb;
  44. var ocspResponders;
  45. var cacheRadio = 0;
  46.  
  47. function onLoad()
  48. {
  49.   var ocspEntry;
  50.   var i;
  51.  
  52.   certdb = Components.classes[nsX509CertDB].getService(nsIX509CertDB);
  53.   ocspResponders = certdb.getOCSPResponders();
  54.  
  55.   var signersMenu = document.getElementById("signingCA");
  56.   var signersURL = document.getElementById("serviceURL");
  57.   for (i=0; i<ocspResponders.length; i++) {
  58.     ocspEntry = ocspResponders.queryElementAt(i, nsIOCSPResponder);
  59.     var menuItemNode = document.createElement("menuitem");
  60.     menuItemNode.setAttribute("value", ocspEntry.responseSigner);
  61.     menuItemNode.setAttribute("label", ocspEntry.responseSigner);
  62.     signersMenu.firstChild.appendChild(menuItemNode);
  63.   }
  64.  
  65.   parent.initPanel('chrome://pippki/content/pref-validation.xul');
  66.  
  67.   doEnabling(0);
  68. }
  69.  
  70. function doEnabling(called_by)
  71. {
  72.   var signingCA = document.getElementById("signingCA");
  73.   var serviceURL = document.getElementById("serviceURL");
  74.   var securityOCSPEnabled = document.getElementById("securityOCSPEnabled");
  75.   var requireWorkingOCSP = document.getElementById("requireWorkingOCSP");
  76.   var enableOCSPBox = document.getElementById("enableOCSPBox");
  77.   var certOCSP = document.getElementById("certOCSP");
  78.   var proxyOCSP = document.getElementById("proxyOCSP");
  79.  
  80.   var OCSPPrefValue = parseInt(securityOCSPEnabled.value);
  81.  
  82.   if (called_by == 0) {
  83.     // the radio button changed, or we init the stored value from prefs
  84.     enableOCSPBox.checked = (OCSPPrefValue != 0);
  85.   }
  86.   else {
  87.     // the user toggled the checkbox to enable/disable OCSP
  88.     var new_val = 0;
  89.     if (enableOCSPBox.checked) {
  90.       // now enabled. if we have a cached radio val, restore it.
  91.       // if not, use the first setting
  92.       new_val = (cacheRadio > 0) ? cacheRadio : 1;
  93.     }
  94.     else {
  95.       // now disabled. remember current value
  96.       cacheRadio = OCSPPrefValue;
  97.     }
  98.     securityOCSPEnabled.value = OCSPPrefValue = new_val;
  99.   }
  100.  
  101.   certOCSP.disabled = (OCSPPrefValue == 0);
  102.   proxyOCSP.disabled = (OCSPPrefValue == 0);
  103.   signingCA.disabled = serviceURL.disabled = OCSPPrefValue == 0 || OCSPPrefValue == 1;
  104.   requireWorkingOCSP.disabled = (OCSPPrefValue == 0);
  105. }
  106.  
  107. function changeURL()
  108. {
  109.   var signersMenu = document.getElementById("signingCA");
  110.   var signersURL = document.getElementById("serviceURL");
  111.   var CA = signersMenu.getAttribute("value");
  112.   var i;
  113.   var ocspEntry;
  114.  
  115.   for (i=0; i < ocspResponders.length; i++) {
  116.     ocspEntry = ocspResponders.queryElementAt(i, nsIOCSPResponder);
  117.     if (CA == ocspEntry.responseSigner) {
  118.       signersURL.setAttribute("value", ocspEntry.serviceURL);
  119.       break;
  120.     }
  121.   }
  122. }
  123.  
  124. function openCrlManager()
  125. {
  126.     window.open('chrome://pippki/content/crlManager.xul',  "",
  127.                 'chrome,centerscreen,resizable');
  128. }
  129.  
  130.